package com.qutan.app.core.domain;

import com.alibaba.fastjson.annotation.JSONField;
import com.i7time.entity.SceneInfo;
import com.i7time.entity.User;
import com.qutan.app.core.domain.enumclass.Whether;
import com.qutan.app.core.utils.AppUtils;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * 场景
 * Created by pengweiyuan on 5/30/16.
 */
@Entity
@Table(name = "scene")
@DynamicInsert(value = true)
@DynamicUpdate(value = true)
public class Scene extends IDEntity{

    @Column(columnDefinition = "bigint(11) comment '用户id' ")
    private long userId;

    @Column(columnDefinition = "varchar (80) comment '房间名字'")
    private String name;

    @Column(columnDefinition = "varchar (80) comment '地址'")
    private String addr;

    @Column(columnDefinition = "varchar (30) comment 'email'")
    private String mail;

    @Column(columnDefinition = "varchar (20) comment '电话'")
    private String tel;

    @Column(columnDefinition = "varchar (20) comment '城市'")
    private String city;

    @Column(columnDefinition = "varchar (80) comment '头像'")
    private String avatar;

    @Column(columnDefinition = "varchar (300) comment '图片'")
    private String pictures;


    @Column(columnDefinition = "double comment '纬度' ")
    private double latitude;

    @Column(columnDefinition = "double comment '经度 '")
    private double longtitude;

    @Column(columnDefinition = "varchar (40) comment 'geohash的值' ")
    private String geohash;


    @Column(columnDefinition = "varchar (40) comment '直播频道号'")
    private String live_channel;

    @Column(columnDefinition = "varchar (40) comment '直播的上传url'")
    private String up_url;

    @Column(columnDefinition = "varchar (40) comment '直播的下载url'")
    private String down_url;

    @Column(columnDefinition = "varchar (40) comment '对应的聊天室id'")
    private String chatroom_id;


    /**
     * 是否在直播中
     */
    @Column(columnDefinition = "varchar (50) comment '直播标志' ")
    @Enumerated(EnumType.STRING)
    private Whether isOnline;


    @Transient
    private List<UserInfo> roomMembers;


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


    public Whether getIsOnline() {
        return isOnline;
    }

    public void setIsOnline(Whether isOnline) {
        this.isOnline = isOnline;
    }

    public List<UserInfo> getRoomMembers() {
        return roomMembers;
    }

    public void setRoomMembers(List<UserInfo> roomMembers) {
        this.roomMembers = roomMembers;
    }

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        this.userId = userId;
    }

    public String getAddr() {
        return addr;
    }

    public void setAddr(String addr) {
        this.addr = addr;
    }

    public String getMail() {
        return mail;
    }

    public void setMail(String mail) {
        this.mail = mail;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getPictures() {
        return pictures;
    }

    public void setPictures(String pictures) {
        this.pictures = pictures;
    }

    public double getLatitude() {
        return latitude;
    }

    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    public double getLongtitude() {
        return longtitude;
    }

    public void setLongtitude(double longtitude) {
        this.longtitude = longtitude;
    }

    public String getGeohash() {
        return geohash;
    }

    public void setGeohash(String geohash) {
        this.geohash = geohash;
    }

    public String getLive_channel() {
        return live_channel;
    }

    public void setLive_channel(String live_channel) {
        this.live_channel = live_channel;
    }

    public String getUp_url() {
        return up_url;
    }

    public void setUp_url(String up_url) {
        this.up_url = up_url;
    }

    public String getDown_url() {
        return down_url;
    }

    public void setDown_url(String down_url) {
        this.down_url = down_url;
    }

    public String getChatroom_id() {
        return chatroom_id;
    }

    public void setChatroom_id(String chatroom_id) {
        this.chatroom_id = chatroom_id;
    }

    public Scene(){

    }

    public Scene(long id,long user_id, String name, String addr, String mail, String tel, String city, String avatar, String pictures, String latitude, String longtitude, String geohash, String live_channel, String up_url, String down_url) {
        this.userId = user_id;
        this.name = name;
        this.addr = addr;
        this.mail = mail;
        this.tel = tel;
        this.city = city;
        this.avatar = avatar;
        this.pictures = pictures;
        this.latitude = Double.parseDouble(latitude);
        this.longtitude = Double.parseDouble(longtitude);
        this.geohash = geohash;
        this.live_channel = live_channel;
        this.up_url = up_url;
        this.down_url = down_url;
        this.id=id;
    }

    @JSONField(serialize = false)
    public SceneInfo conver2SceneInfo(){
        SceneInfo info=new SceneInfo(id,userId,name,addr,mail,tel,city,avatar,pictures,latitude,longtitude,geohash,live_channel,up_url,down_url,chatroom_id);
        return  info;
    }


}
